package cn.lili.modules.grab.factory.notice;

import cn.lili.common.utils.SpringContextUtil;
import cn.lili.modules.grab.GrabNoticeParam;
import cn.lili.modules.grab.dingdong.base.BaseResult;
import cn.lili.modules.grab.enums.SourceEnums;
import cn.lili.modules.grab.factory.order.GrabOrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
@RequiredArgsConstructor
public class GrabNoticeFactory {

    private final List<GrabNoticeService> noticeServiceList;

    /**
     * 订单回调工厂
     *
     * @param grabParam 参数
     */
    public BaseResult orderCallback(GrabNoticeParam grabParam) {
        GrabNoticeService grabNoticeService = noticeServiceList.stream().filter(service -> service.step().name().equals(grabParam.getCode())).findFirst().get();
        return grabNoticeService.orderCallback(grabParam);
    }

    /**
     * 商品回调工厂
     *
     * @param grabParam 参数
     */
    public BaseResult goodsCallback(GrabNoticeParam grabParam) {
        GrabNoticeService grabNoticeService = noticeServiceList.stream().filter(service -> service.step().name().equals(grabParam.getCode())).findFirst().get();
        return grabNoticeService.goodsCallback(grabParam);
    }
}
